<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //传统写法
        function fun(n) {
            return n * 2;
        }
        console.info(fun(3)); //6


        //ES5
        var method = function(n) {
            return n * n;
        }
        console.info(method(5)); //25


        //ES6 箭头函数的语法  表达式：()=>{} 也可以传参
        var getNum = (n) => {
            return n * (n - 1);
        }
        console.info(getNum(5)); //20


        //如果方法体只有一句代码可以不写{}也不用写return
        var getNum2 = (n) => n * (n + 1);
        console.info(getNum2(2)); //6
    </script>
</head>

<body>





</body>

</html>